import { UserState } from '@/store/modules/user/types'
import axios from 'axios'
import type { RouteRecordNormalized } from 'vue-router'
import { encrypt } from '@/utils/cyrptoUtil'

export interface LoginData {
  username: string
  password: string
  password_encrypt : string
}

export function login(data: LoginData) {
  data.password_encrypt = encrypt(data.password)
  //return axios.post('/user/login', data)
  return {code : 200, msg : "操作成功", data:{"X-TOKEN" : "1234567890"}}
}

export function signInWx(data:Object) {
  //return axios.post('/user/wxlogin', data)
  return {code : 200, msg : "操作成功", data:{"X-TOKEN" : "1234567890"}}
}

export function logout() {
  //return axios.post('/user/logout')
  return {code : 200, msg : "操作成功", data:{}}
}

export function getUserInfo() {
  //return axios.post<UserState>('/user/info', {'test' : 'test'})
  return {"code" : 200, "msg" : "操作成功", data:{name : "admin", avatar : "", role:["1", "2"]}}
}

export function getMenuList() {
  return axios.post<RouteRecordNormalized[]>('/api/user/menu')
}
